package bramar.all;

import java.sql.Connection;
import java.sql.DriverManager;

 
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

 
public class OracleToAccess {

   public OracleToAccess() throws ClassNotFoundException, SQLException
   {
Class.forName("oracle.jdbc.driver.OracleDriver");
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection ocon=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:XE","scott","tiger");
Connection acon=DriverManager.getConnection("jdbc:odbc:accdsn");
Statement st=ocon.createStatement();
PreparedStatement ps=acon.prepareStatement("insert into dept values(?,?,?)");
ResultSet rs=st.executeQuery("select * from dept");
while(rs.next())
{
    int no=rs.getInt(1);
    String name=rs.getString(2);
    String addrs=rs.getString(3);
    ps.setInt(1,no);
    ps.setString(2,name);
    ps.setString(3,addrs);
    ps.executeUpdate();
      
}        
 System.out.println("Records are moved successfully from Oracle to Ms-Access");
 rs.close();
 st.close();
 ps.close();
 acon.close();
 ocon.close();
 
    }

}
